/* ************************************************************************************************

	Copyright (c) 2005-2006, IGR
	All Rights Reserved.
	Licensed under the Apache License version 2.0 or above.
	For more information on licensing, see:
        http://www.apache.org/licenses/


 ************************************************************************************************
 Objet LABEL
 VERSION:0.85
 DATE:16/03/2006
 ************************************************************************************************
Init parameter :
 Name:               Code name
 top:           	 Top position (in pixel)
 left:               Left position (in pixel)             
 parent              object parent
 text:               text of the label
 className:          class name of the label
 objPar              object of parameter    
*************************************************************************************************/


// *************************************
// CONSTRUCTOR
// *************************************

rialto.widget.Label=function(name,top,left,parent,text,className,objPar){
	//base object parameter
    var objParam=new Object;
  	objParam.name=name;
	objParam.type="label";
    objParam.left=left;
	objParam.top=top;
	if (objPar != null){objParam.position=objPar.position;}
	//base constructor
	this.base = rialto.widget.AbstractComponent;    
    this.base(objParam);

	//release object
	objPar=null;
	objParam=null;
        
    this.text=text;
    if (className !='' && className!=null){
    	this.className=className;
     }
     else{
     	this.className="libNormal";
     }        

    var oThis=this;  
 
    // *******************************************
	// GENERATION OF DOM ELEMENTS
	// *******************************************
	
    this.divExt.id = this.id + "_DivGen";
    this.divExt.style.position = this.position;   
    this.divExt.style.left = this.left + "px";
    this.divExt.style.top = this.top + "px";        
    this.divExt.style.width =this.getTailleTexte()+"px";           
    this.divExt.className = this.className;
    this.divExt.style.overflow='hidden';    
    this.divExt.style.textOverflow="ellipsis";
    this.divExt.style.whiteSpace="nowrap";         
    this.divExt.title=this.text;    
    // Text of the label
    this.divExt.innerHTML=this.text;
        
    //add to the parent
    if (parent) {this.placeIn(parent);};        
    
} 

rialto.widget.Label.prototype = new rialto.widget.AbstractComponent;

rialto.widget.Label.prototype.getTailleTexte=function(wText) {
    //To get the width of the text wit th is classname
    var text=wText ? wText :this.text;
    return getTailleTexte(text,this.className);	            
}
  

//******this METHOD IS DEPRECATED...USE SETTEXT
rialto.widget.Label.prototype.changeLibelle=function(text){    
    rialto.deprecated('Label','changeLibelle','setText');
    this.setText(text);
}
//******

rialto.widget.Label.prototype.setText=function(text){
    // new text   
    this.text=text;
    this.divExt.innerHTML=this.text;    
    this.divExt.title=this.text;
    this.divExt.style.width =this.getTailleTexte()+"px";
}


//******those 2 METHODS ARE DEPRECATED...USE SETVISIBLE
//to hide
rialto.widget.Label.prototype.masqueLibelle=function() {
	rialto.deprecated('Label','masqueLibelle','setVisible(false)');
    this.setVisible(false);
    this.masque=true;  
}
//to show
rialto.widget.Label.prototype.afficheLibelle=function() {
    rialto.deprecated('Label','afficheLibelle','setVisible(true)');
    this.setVisible(true);
    this.masque=false;
}
//******


//******those 2 METHODS ARE DEPRECATED...USE SETENABLE
//to enable
rialto.widget.Label.prototype.active=function() {
    rialto.deprecated('Label','active','setEnable(true)');
    this.setEnable(true);    
}
//to desable
rialto.widget.Label.prototype.inactive=function() {
    rialto.deprecated('Label','inactive','setEnable(false)');
    this.setEnable(false);
}
//******

//this method will allow to enable or disable the label according to the parameter
rialto.widget.Label.prototype.setEnable=function(enable){
	if(enable){
		this.divExt.className = this.className;
	}
	else{
		this.divExt.className += " inactif";
	}
	this.enable=enable;
}
